package Collections;

import java.util.ArrayList;
import java.util.Collections;

/*
 * 模拟都地主发牌
 */
public class CollectionsTest {
	public static void main(String[] args) {
		//买牌
		String[] arr = {"黑桃","红桃","方片","梅花"};
		String[] arr2 = {"A","1","2","3","4","5","6","7","8","9","10","J","Q","K"};
		ArrayList<String> box = new ArrayList<String>();
		//添加每张牌
		for(int i=0;i<arr.length;i++) {
			for(int j=0;j<arr2.length;j++) {
				 box.add(arr[i]+arr2[j]);
			}
		}
		box.add("大王");
		box.add("小王");
//		System.out.println(box);
		//洗牌
		Collections.shuffle(box);
		System.out.println(box);
		//发牌
		ArrayList<String> zhangsan = new ArrayList<String>();
		ArrayList<String> lisi = new ArrayList<String>();
		ArrayList<String> wangwu = new ArrayList<String>();
		
		for(int i=0;i<box.size()-3;i++) {
			/*
			 * i=0;i%3=0
			 * i=1;i%3=1
			 * i=2;i%3=2
			 * i=3;i%3=0
			 */
			if(i%3 == 0) {
				zhangsan.add(box.get(i));
			}
			if(i%3 == 1) {
				lisi.add(box.get(i));
			}
			if(i%3==2) {
				wangwu.add(box.get(i));
			}
		}
		System.out.println("zhangsan:"+zhangsan);
		System.out.println("lisi:" + lisi);
		System.out.println("wangwu:"+wangwu);
		System.out.println("底牌:");
		for(int i=box.size()-3;i<box.size();i++) {
			System.out.println(box.get(i));
		}
		
	}
	
}
